module test
    implicit none
    type m
        class(*),allocatable::a
    contains
        procedure,pass::init
        procedure,pass::write_m
        generic::assignment(=)=>init
    end type
contains
    elemental subroutine init(this,a)
        class(m),intent(inout)::this
        class(*),intent(in)::a
        allocate(this%a,source=a)
    end subroutine init 

    impure elemental subroutine write_m(this)
        class(m),target,intent(in)::this
        class(*),pointer::in=>NULL()
        in=>this%a
        select type(in)
        type is(real)
            write(*,*)in
        type is(integer)
            write(*,*)in
        end select
    end subroutine write_m
end module test

program main
    use test
    implicit none
    type(m)::x(4)
    x(1)=1
    x(2)=2.0
    x(3:4)=[3,5]
    call x%write_m()
end program main
